package com.ruoyi.back.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.PageData
import com.ruoyi.app.common.pageInfo
import com.ruoyi.back.domain.ChannelManager
import com.ruoyi.back.service.ChannelManagerService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiImplicitParams
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("system/channelManager")
@Api(tags = ["渠道管理"])
class ChannelManagerController {

    @Autowired
    private lateinit var channelManagerService: ChannelManagerService


    @ApiOperation("保存app 渠道信息")
    @PostMapping("save")
    fun saveChannelManager(@RequestBody channelManager: ChannelManager): Data<Boolean> = channelManagerService.saveChannelManager(channelManager)

    @ApiOperation("app 渠道信息分页")
    @GetMapping("list")
    fun channelManagerPage(channelManager: ChannelManager): PageData<ChannelManager> = channelManagerService.channelManagerPage(channelManager).pageInfo()

    @ApiOperation("移除app 渠道信息")
    @ApiImplicitParams(
        ApiImplicitParam(name = "channelIds", value = "渠道id 多个使用逗号", type = "path", required = true)
    )
    @PostMapping("remove/{channelIds}")
    fun removeChannelManager(@PathVariable channelIds: String): Data<Boolean> = channelManagerService.removeChannelManager(channelIds)
}